﻿
using System ;
using System.Diagnostics ;

using MskEdit.Sdk ;


namespace MskEdit.Dxf.Representation
{
    public static class DxfCodeValuePair
    {
    
        public static string TryFindFirstValue( string[] allLines, SdkSubrange subrange, string code, string fallbackValue ) {

            Debug.Assert( !string.IsNullOrEmpty( code ) ) ;
            
            int i = subrange.Begin ;
            for (; ( i < subrange.End ) && ! allLines[i].Equals( code ); i += 2 ) ;

            if ( i >= subrange.End )
                return fallbackValue ;
            
            return allLines[i + 1] ;
        }

    }
}
